home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Lose Your Marbles! 1.0 / source / ls code ƒ / ls.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  2.4 KB  |  94 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        ls.c
  4.  
  5. Purpose:    This module handles game initialization/shutdown and
  6.             starting new games (from scratch or from disk).
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "ls.h"
  26. #include "program globals.h"
  27. #include "graphics.h"
  28. #include "file interface.h"
  29. #include "error.h"
  30. #include "menus.h"
  31. #include "ls load-save.h"
  32. #include "ls endgame.h"
  33. #include "ls find.h"
  34. #include "ls main window.h"
  35.  
  36. short            gNumRows, gNumColumns;
  37. short            gCurrentRow, gCurrentColumn;
  38. short            gNumMoves;
  39. short            Board[MAX_ROWS][MAX_COLS];
  40. Point            gMoves[MAX_ROWS*MAX_COLS];
  41. CIconHandle        gTheCIcon[10];
  42. Handle            gTheIcon[10];
  43.  
  44. void InitTheProgram(void)
  45. {
  46.     short            i,j,k;
  47.     AppFile            myFile;
  48.     
  49.     CallIndDispatchProc(kHelp, kStartup, 0L);
  50.     SetIndDispatchProc(kMainWindow, MainWindowDispatch);
  51.     CallIndDispatchProc(kMainWindow, kStartup, 0L);
  52.     
  53.     InitTheEndGame();
  54.     InitFind();
  55.     
  56.     CountAppFiles(&i, &j);
  57.     if ((j>0) && (i==0))
  58.     {
  59.         GetAppFiles(1, &myFile);
  60.         MyMakeFSSpec(myFile.vRefNum, 0, myFile.fName, &gameFile);
  61.         HandleError(GetSavedGame(&gameFile), FALSE);
  62.         for (k=1; k<=j; k++)
  63.             ClrAppFiles(k);
  64.     }
  65. }
  66.  
  67. void NewGame(void)
  68. {
  69.     short            i,j;
  70.     
  71. // init game globals here, stuff that would be saved to disk in saved game
  72.     for (i=0; i<MAX_ROWS; i++)
  73.         for (j=0; j<MAX_COLS; j++)
  74.             Board[i][j]=0;
  75.     gNumMoves=0;
  76.     gCurrentRow=gCurrentColumn=0;
  77.     InitLoadSave();
  78.     StartGame();
  79. }
  80.  
  81. void StartGame(void)
  82. {
  83. // init game globals here, stuff that always needs to be initted
  84.     OpenTheIndWindow(kMainWindow);
  85.     AdjustMenus();
  86.     DrawMenuBar();
  87. }
  88.  
  89. void ShutDownTheProgram(void)
  90. {
  91.     ShutDownTheEndGame();
  92.     CallIndDispatchProc(kMainWindow, kShutdown, 0L);
  93. }
  94.